package com.bluebridgecup.javabasics;

import java.util.Scanner;

public class GreatestCommonDivisorFinderMax {
    // 欧几里得算法，求最大公约数
    // 时间复杂度O(log(min(a,b)))
    public static int gcd(int a, int b) {
        if (b == 0) return a;
        return gcd(b, a % b);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        System.out.println(gcd(a, b));
        in.close();
    }
}
